#pragma once
#include "DialogEventHandler.h"
#include "DXUTmisc.h"
// IDs for the Task Dialog Buttons
#define IDC_XYZFILEOPEN                       100

#define STRXYZFILENAME 0

class CDialogFileIO
{
public:
	CDialogFileIO(){}
	~CDialogFileIO()
	{ 
		if(m_strArray.GetSize()>0)
		{ 
			for(int i = 0; i < m_strArray.GetSize(); i++)
				SAFE_DELETE_ARRAY(m_strArray[i]);
		}
	}
	//menu function
	int BasicUtilityMenu();
	//subbutton function
	HRESULT XYZFileOpen();
	
	//utility function
	const WCHAR* GetWString(int iIdx)
	{
		if(m_strArray.GetSize() > iIdx)
		{
			printf("No string exists\n");
			return NULL;
		}
		else
			return m_strArray[iIdx];
	}
	int AddString(int iIdx, WCHAR* pStr)
	{
		if(pStr == NULL) 
		{
			printf("the input string is NULL\n");
			return -1;
		}
		if(m_strArray.GetSize() > iIdx)
		{
			printf("Overwrite the original string\n");
			int iStrLen = wcslen(pStr);
			WCHAR* pDst = m_strArray[iIdx];
			wcscpy(pDst, pStr);
			pDst[iStrLen] = '\0';
			return 0;
		}
		else
		{
			printf("Add new string\n");
			WCHAR* pDst = new WCHAR[MAX_PATH];
			memset(pDst,0,sizeof(WCHAR)*MAX_PATH);
			wcscpy(pDst, pStr);
			return 1;
		}
	}
	HRESULT CDialogEventHandler_CreateInstance(REFIID riid, void **ppv);


private:
	CGrowableArray<WCHAR*> m_strArray;
};
